package com.elli0tt.session;

import com.elli0tt.pojo.Configuration;

/**
 * @author elli0tt
 * @version 1.0
 * @className DefaultSqlSessionFactory.java
 * @description 默认 SqlSession 工厂
 * @createTime 2020-08-28 23:12:39
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {

    private final Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public SqlSession openSession() {
        return new DefaultSqlSession(configuration);
    }

    @Override
    public SqlSession openSession(boolean autoCommit) {
        this.configuration.setAutoCommit(autoCommit);
        return new DefaultSqlSession(configuration);
    }
}
